
<!DOCTYPE html>
<html lang="zh-Hans" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Java导出Excel文档（poi），并上传到腾讯云对象存储服务器 - Luis Blog</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="Luis,"> 
    <meta name="description" content="java开发工程师，喜欢代码，喜欢技术,
需求后台生成周报月报季报年报Excel，将文件下载链接推送给对应客户


开发思路：1.根据选定日期生成周报，月报，季报，年报数据2.将这些数据报告生成Excel表格3.把生成的文件上传到腾讯云对,"> 
    <meta name="author" content="winter chen"> 
    <link rel="alternative" href="atom.xml" title="Luis Blog" type="application/atom+xml"> 
    <link rel="icon" href="/img/favicon.png"> 
    
    
<link rel="stylesheet" href="/css/diaspora.css">

	<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({
              google_ad_client: "ca-pub-8691406134231910",
              enable_page_level_ads: true
         });
    </script>
    <script async custom-element="amp-auto-ads"
        src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">
    </script>
<meta name="generator" content="Hexo 4.2.0"></head>

<body class="loading">
    <span id="config-title" style="display:none">Luis Blog</span>
    <div id="loader"></div>
    <div id="single">
    <div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <a class="iconfont icon-home image-icon" href="javascript:;" data-url="https://blog.winterchen.com"></a>
    <div title="播放/暂停" class="iconfont icon-play"></div>
    <h3 class="subtitle">Java导出Excel文档（poi），并上传到腾讯云对象存储服务器</h3>
    <div class="social">
        <div>
            <div class="share">
                <a title="获取二维码" class="iconfont icon-scan" href="javascript:;"></a>
            </div>
            <div id="qr"></div>
        </div>
    </div>
    <div class="scrollbar"></div>
</div>

    <div class="section">
        <div class="article">
    <div class='main'>
        <h1 class="title">Java导出Excel文档（poi），并上传到腾讯云对象存储服务器</h1>
        <div class="stuff">
            <span>十月 21, 2017</span>
            
  <ul class="post-tags-list" itemprop="keywords"><li class="post-tags-list-item"><a class="post-tags-list-link" href="/tags/java/" rel="tag">java</a></li><li class="post-tags-list-item"><a class="post-tags-list-link" href="/tags/poi/" rel="tag">poi</a></li></ul>


        </div>
        <div class="content markdown">
            <p><img src="http://img.winterchen.com/john-salzarulo-342868-unsplash.jpg" alt=""></p>
<h3 id="需求"><a href="#需求" class="headerlink" title="需求"></a>需求</h3><p><strong>后台生成周报月报季报年报Excel，将文件下载链接推送给对应客户</strong></p>
<a id="more"></a>

<h3 id="开发思路："><a href="#开发思路：" class="headerlink" title="开发思路："></a>开发思路：</h3><p><strong>1.根据选定日期生成周报，月报，季报，年报数据</strong><br><strong>2.将这些数据报告生成Excel表格</strong><br><strong>3.把生成的文件上传到腾讯云对象存储服务器</strong><br><strong>4.将服务器返回的url存储到数据库</strong></p>
<h3 id="工具"><a href="#工具" class="headerlink" title="工具"></a>工具</h3><p><strong><a href="http://download.csdn.net/download/yaosir12/9475344" target="_blank" rel="noopener">poi-3.14-20160307.jar(点击可下载)</a></strong></p>
<h3 id="数据"><a href="#数据" class="headerlink" title="数据"></a>数据</h3><p>获取数据部分省略了</p>
<h3 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h3><p><strong>主方法</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">addReportExcelToCloud</span><span class="params">(ReportResult rr)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">		OutputStream out = <span class="keyword">new</span> ByteArrayOutputStream();</span><br><span class="line">		ExcelProjectUtils eu = <span class="keyword">new</span> ExcelProjectUtils();</span><br><span class="line">		eu.exportExcel(rr, out);   <span class="comment">//&lt;1&gt;</span></span><br><span class="line">		ConvertUtil cu = <span class="keyword">new</span> ConvertUtil();</span><br><span class="line">		<span class="keyword">try</span> &#123;</span><br><span class="line">			ByteArrayInputStream byteInput = cu.parse(out);</span><br><span class="line">			String rs = PicUploadToYun.uploadExcel(SysContent.getFileRename(<span class="string">"案场数据报.xls"</span>), byteInput);  <span class="comment">//&lt;2&gt;</span></span><br><span class="line">			addReportExcelToDB(rr, rs);  <span class="comment">//&lt;3&gt;</span></span><br><span class="line">			<span class="keyword">return</span> <span class="keyword">true</span>;</span><br><span class="line">		&#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		<span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>
<p>&lt;1&gt; 将数据生成二进制Excel文件 (方法详细见下面代码)<br>&lt;2&gt; 将生成的二进制文件上传到腾讯云对象存储服务器 (方法详细见下面代码)<br>&lt;3&gt; 将服务器返回的url存储到数据库 (方法详细见下面代码)</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 周报年报生成excel</span></span><br><span class="line"><span class="comment">	 * </span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> report</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> out</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">exportExcel</span><span class="params">(ReportResult report, OutputStream out)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 判断传入的时间间隔</span></span><br><span class="line">		String dateStr = <span class="string">""</span>;</span><br><span class="line">		String reportName = <span class="string">""</span>;</span><br><span class="line">		List&lt;String&gt; dateCount = DateUtil.getTwoDateEveryDay(report.getStartTime(), report.getEndTime());</span><br><span class="line">		<span class="keyword">if</span> (dateCount.size() &lt;= <span class="number">7</span>) &#123;</span><br><span class="line">			dateStr += <span class="string">"本周"</span>;</span><br><span class="line">			reportName += <span class="string">"案场周报"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (dateCount.size() &gt;= <span class="number">28</span> &amp;&amp; dateCount.size() &lt;= <span class="number">31</span>) &#123;</span><br><span class="line">			dateStr += <span class="string">"本月"</span>;</span><br><span class="line">			reportName += <span class="string">"案场月报"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (dateCount.size() &gt;= <span class="number">85</span> &amp;&amp; dateCount.size() &lt;= <span class="number">100</span>) &#123;</span><br><span class="line">			dateStr += <span class="string">"本季度"</span>;</span><br><span class="line">			reportName += <span class="string">"案场季报"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (dateCount.size() &gt;= <span class="number">180</span> &amp;&amp; dateCount.size() &lt;= <span class="number">185</span>) &#123;</span><br><span class="line">			dateStr += <span class="string">"本半年度"</span>;</span><br><span class="line">			reportName += <span class="string">"案场半年报"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (dateCount.size() &gt;= <span class="number">360</span> &amp;&amp; dateCount.size() &lt;= <span class="number">367</span>) &#123;</span><br><span class="line">			dateStr += <span class="string">"本年度"</span>;</span><br><span class="line">			reportName += <span class="string">"案场年报"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">			dateStr += <span class="string">"时间段内"</span>;</span><br><span class="line">			reportName += <span class="string">"案场阶段报"</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		report.setReportName(reportName);</span><br><span class="line">		<span class="comment">// 声明一个工作薄</span></span><br><span class="line">		HSSFWorkbook workbook = <span class="keyword">new</span> HSSFWorkbook();</span><br><span class="line">		<span class="comment">// 生成一个表格</span></span><br><span class="line">		HSSFSheet sheet = workbook.createSheet(report.getReportName() + report.getStartTime() + <span class="string">" - "</span> + report.getEndTime());</span><br><span class="line">		<span class="comment">// 设置表格默认列宽度为100个字节</span></span><br><span class="line">		sheet.setDefaultColumnWidth((<span class="keyword">short</span>) <span class="number">100</span>);</span><br><span class="line">		<span class="comment">/** ----------样式一：标题 ------------ **/</span></span><br><span class="line">		HSSFCellStyle style = workbook.createCellStyle();</span><br><span class="line">		<span class="comment">// 设置这些样式</span></span><br><span class="line">		style.setBorderLeft(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		style.setBorderRight(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		<span class="comment">//style.setBorderTop(HSSFCellStyle.BORDER_THIN);</span></span><br><span class="line">		style.setAlignment(HSSFCellStyle.ALIGN_CENTER);</span><br><span class="line">		<span class="comment">// 生成一个字体</span></span><br><span class="line">		HSSFFont font = workbook.createFont();</span><br><span class="line">		font.setFontName(<span class="string">"宋体"</span>);</span><br><span class="line">		<span class="comment">//font.setColor(HSSFColor.VIOLET.index);</span></span><br><span class="line">		font.setFontHeightInPoints((<span class="keyword">short</span>) <span class="number">14</span>);</span><br><span class="line">		font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);</span><br><span class="line">		<span class="comment">// 把字体应用到当前的样式</span></span><br><span class="line">		style.setFont(font);</span><br><span class="line">		<span class="comment">/***---------样式二：小标题---------***/</span></span><br><span class="line">		HSSFCellStyle style2 = workbook.createCellStyle();</span><br><span class="line">		style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		style2.setBorderRight(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		<span class="comment">//style2.setBorderTop(HSSFCellStyle.BORDER_THIN);</span></span><br><span class="line">		style2.setAlignment(HSSFCellStyle.ALIGN_LEFT);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);</span></span><br><span class="line">		<span class="comment">// 生成另一个字体</span></span><br><span class="line">		HSSFFont font2 = workbook.createFont();</span><br><span class="line">		<span class="comment">//font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);</span></span><br><span class="line">		font2.setFontName(<span class="string">"宋体"</span>);</span><br><span class="line">		font2.setFontHeightInPoints((<span class="keyword">short</span>) <span class="number">11</span>);</span><br><span class="line">		font2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);</span><br><span class="line">		<span class="comment">// 把字体应用到当前的样式</span></span><br><span class="line">		style2.setFont(font2);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">/***    样式三：右侧日期       ***/</span></span><br><span class="line">		HSSFCellStyle style3 = workbook.createCellStyle();</span><br><span class="line">		<span class="comment">//样式</span></span><br><span class="line">		style3.setBorderLeft(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		style3.setBorderRight(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		style3.setAlignment(HSSFCellStyle.ALIGN_RIGHT);</span><br><span class="line">		style3.setBorderBottom(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		<span class="comment">//字体</span></span><br><span class="line">		HSSFFont font3 = workbook.createFont();</span><br><span class="line">		font3.setFontName(<span class="string">"宋体"</span>);</span><br><span class="line">		font3.setFontHeightInPoints((<span class="keyword">short</span>) <span class="number">11</span>);</span><br><span class="line">		style3.setFont(font3);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">/**       样式四：主内容        ***/</span></span><br><span class="line">		HSSFCellStyle style4 = workbook.createCellStyle();</span><br><span class="line">		<span class="comment">//样式</span></span><br><span class="line">		style4.setBorderLeft(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		style4.setBorderRight(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		style4.setAlignment(HSSFCellStyle.ALIGN_LEFT);</span><br><span class="line">		<span class="comment">//字体</span></span><br><span class="line">		HSSFFont font4 = workbook.createFont();</span><br><span class="line">		font4.setFontName(<span class="string">"宋体"</span>);</span><br><span class="line">		font4.setFontHeightInPoints((<span class="keyword">short</span>) <span class="number">11</span>);</span><br><span class="line">		style4.setFont(font4);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">/**       样式五：底侧空内容       ***/</span></span><br><span class="line">		HSSFCellStyle style5 = workbook.createCellStyle();</span><br><span class="line">		<span class="comment">//样式</span></span><br><span class="line">		style5.setBorderLeft(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		style5.setBorderRight(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		style5.setAlignment(HSSFCellStyle.ALIGN_LEFT);</span><br><span class="line">		style5.setBorderBottom(HSSFCellStyle.BORDER_THIN);</span><br><span class="line">		<span class="comment">//字体</span></span><br><span class="line">		HSSFFont font5 = workbook.createFont();</span><br><span class="line">		font5.setFontName(<span class="string">"宋体"</span>);</span><br><span class="line">		font5.setFontHeightInPoints((<span class="keyword">short</span>) <span class="number">11</span>);</span><br><span class="line">		style5.setFont(font5);</span><br><span class="line">		</span><br><span class="line">		</span><br><span class="line">		<span class="comment">// 声明一个画图的顶级管理器</span></span><br><span class="line">		HSSFPatriarch patriarch = sheet.createDrawingPatriarch();</span><br><span class="line">		<span class="comment">// 定义注释的大小和位置,详见文档</span></span><br><span class="line">		HSSFComment comment = patriarch.createComment(<span class="keyword">new</span> HSSFClientAnchor(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, (<span class="keyword">short</span>) <span class="number">4</span>, <span class="number">2</span>, (<span class="keyword">short</span>) <span class="number">6</span>, <span class="number">5</span>));</span><br><span class="line">		<span class="comment">// 设置注释内容</span></span><br><span class="line">		comment.setString(<span class="keyword">new</span> HSSFRichTextString(<span class="string">"数据报"</span>));</span><br><span class="line">		<span class="comment">// 设置注释作者，当鼠标移动到单元格上是可以在状态栏中看到该内容.</span></span><br><span class="line">		comment.setAuthor(<span class="string">"saas"</span>);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 产生表格标题行 -- 项目名称</span></span><br><span class="line">		HSSFRow row = sheet.createRow(<span class="number">0</span>);</span><br><span class="line">		createCellAndRow(style4, report.getProjectName(), row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 产生表格标题行 -- 周报名称</span></span><br><span class="line">		row = sheet.createRow(<span class="number">1</span>);</span><br><span class="line">		createCellAndRow(style, report.getReportName(), row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 产生表格标题行 -- 起始时间-终止时间</span></span><br><span class="line">		row = sheet.createRow(<span class="number">2</span>);</span><br><span class="line">		String startTime = DateUtil.format(DateUtil.parse(report.getStartTime(), DateUtil.PATTERN_CLASSICAL_SIMPLE),</span><br><span class="line">				DateUtil.PATTERN_CLASSICAL_SIMPLE_YMD);</span><br><span class="line">		String endTime = DateUtil.format(DateUtil.parse(report.getEndTime(), DateUtil.PATTERN_CLASSICAL_SIMPLE),</span><br><span class="line">				DateUtil.PATTERN_CLASSICAL_SIMPLE_YMD);</span><br><span class="line">		String date = <span class="string">"日期："</span> + startTime + <span class="string">" - "</span> + endTime;</span><br><span class="line">		createCellAndRow(style3, date, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 接访情况标题</span></span><br><span class="line">		row = sheet.createRow(<span class="number">3</span>);</span><br><span class="line">		createCellAndRow(style2, <span class="string">"·接访情况"</span>, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 接访客户组数</span></span><br><span class="line">		row = sheet.createRow(<span class="number">4</span>);</span><br><span class="line">		Integer visitCount = report.getVisitCount();</span><br><span class="line">		String visitNum = <span class="string">"1、"</span> + dateStr + <span class="string">"共计接访客户"</span> + visitCount + <span class="string">"组，来访量"</span>;</span><br><span class="line">		<span class="keyword">if</span> (visitCount &lt; <span class="number">40</span>) &#123;</span><br><span class="line">			visitNum += <span class="string">"较少，有待提升"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (visitCount &gt;= <span class="number">41</span> &amp;&amp; visitCount &lt;= <span class="number">99</span>) &#123;</span><br><span class="line">			visitNum += <span class="string">"尚可，还有提高空间"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (visitCount &gt;= <span class="number">100</span> &amp;&amp; visitCount &lt;= <span class="number">139</span>) &#123;</span><br><span class="line">			visitNum += <span class="string">"很多"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (visitCount &gt; <span class="number">140</span>) &#123;</span><br><span class="line">			visitNum += <span class="string">"火爆"</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		createCellAndRow(style4, visitNum, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 有效接访率</span></span><br><span class="line">		row = sheet.createRow(<span class="number">5</span>);</span><br><span class="line">		Double visitRate = <span class="keyword">new</span> Double(report.getValidVisitRate());</span><br><span class="line">		String visitRateStr = <span class="string">"2、有效接访率为"</span> + visitRate + <span class="string">"%，接访成效"</span>;</span><br><span class="line">		<span class="keyword">if</span> (visitRate &lt; <span class="number">50</span>) &#123;</span><br><span class="line">			visitRateStr += <span class="string">"较低，有待提升"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (visitRate &gt;= <span class="number">50</span> &amp;&amp; visitRate &lt;= <span class="number">65</span>) &#123;</span><br><span class="line">			visitRateStr += <span class="string">"尚可，还有提高空间"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (visitRate &gt;= <span class="number">65</span> &amp;&amp; visitRate &lt;= <span class="number">80</span>) &#123;</span><br><span class="line">			visitRateStr += <span class="string">"很高"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (visitRate &gt; <span class="number">80</span>) &#123;</span><br><span class="line">			visitRateStr += <span class="string">"极高"</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		createCellAndRow(style4, visitRateStr, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 首访有效率</span></span><br><span class="line">		row = sheet.createRow(<span class="number">6</span>);</span><br><span class="line">		Double newVisitRate = <span class="keyword">new</span> Double(report.getValidNewCuVisitRate());</span><br><span class="line">		String newVisitStr = <span class="string">"3、首访有效率为"</span> + newVisitRate + <span class="string">"%，来访转储客的概率"</span>;</span><br><span class="line">		<span class="keyword">if</span> (newVisitRate &lt; <span class="number">40</span>) &#123;</span><br><span class="line">			newVisitStr += <span class="string">"较差，有待提升"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (newVisitRate &gt;= <span class="number">40</span> &amp;&amp; newVisitRate &lt;= <span class="number">60</span>) &#123;</span><br><span class="line">			newVisitStr += <span class="string">"尚可，还有提高空间"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (newVisitRate &gt;= <span class="number">60</span> &amp;&amp; newVisitRate &lt;= <span class="number">75</span>) &#123;</span><br><span class="line">			newVisitStr += <span class="string">"很高"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (newVisitRate &gt; <span class="number">75</span>) &#123;</span><br><span class="line">			newVisitStr += <span class="string">"极高"</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		createCellAndRow(style4, newVisitStr, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 老客户接访占比</span></span><br><span class="line">		row = sheet.createRow(<span class="number">7</span>);</span><br><span class="line">		Double oldVisitRate = <span class="keyword">new</span> Double(report.getOldCuVisitRate());</span><br><span class="line">		String oldVisitStr = <span class="string">"4、老客户接访比为"</span> + oldVisitRate + <span class="string">"%，老客户接访的占比"</span>;</span><br><span class="line">		<span class="keyword">if</span> (oldVisitRate &lt; <span class="number">20</span>) &#123;</span><br><span class="line">			oldVisitStr += <span class="string">"较低"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (oldVisitRate &gt;= <span class="number">20</span> &amp;&amp; oldVisitRate &lt;= <span class="number">40</span>) &#123;</span><br><span class="line">			oldVisitStr += <span class="string">"尚可"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (oldVisitRate &gt;= <span class="number">40</span> &amp;&amp; oldVisitRate &lt;= <span class="number">60</span>) &#123;</span><br><span class="line">			oldVisitStr += <span class="string">"很高"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (oldVisitRate &gt; <span class="number">60</span>) &#123;</span><br><span class="line">			oldVisitStr += <span class="string">"极高"</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		createCellAndRow(style4, oldVisitStr, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">//空行</span></span><br><span class="line">		row = sheet.createRow(<span class="number">8</span>);</span><br><span class="line">		createCellAndRow(style4, <span class="string">""</span>, row);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">// 储客情况</span></span><br><span class="line">		row = sheet.createRow(<span class="number">9</span>);</span><br><span class="line">		createCellAndRow(style2, <span class="string">"·储客情况"</span>, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 新增储客</span></span><br><span class="line">		row = sheet.createRow(<span class="number">10</span>);</span><br><span class="line">		Integer newCuCount = report.getNewCuCount();</span><br><span class="line">		String newCuStr = <span class="string">"1、"</span> + dateStr + <span class="string">"新增储客"</span> + newCuCount + <span class="string">"组，新增量"</span>;</span><br><span class="line">		<span class="keyword">if</span> (newCuCount &lt; <span class="number">30</span>) &#123;</span><br><span class="line">			newCuStr += <span class="string">"较少，有待提升"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (newCuCount &gt;= <span class="number">31</span> &amp;&amp; newCuCount &lt;= <span class="number">60</span>) &#123;</span><br><span class="line">			newCuStr += <span class="string">"尚可，还有提高空间"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (newCuCount &gt;= <span class="number">61</span> &amp;&amp; newCuCount &lt;= <span class="number">79</span>) &#123;</span><br><span class="line">			newCuStr += <span class="string">"很多"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (newCuCount &gt; <span class="number">80</span>) &#123;</span><br><span class="line">			newCuStr += <span class="string">"爆满"</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		createCellAndRow(style4, newCuStr, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 累计老客户</span></span><br><span class="line">		row = sheet.createRow(<span class="number">11</span>);</span><br><span class="line">		Integer oldCuCount = report.getTotalOldCuCount();</span><br><span class="line">		Integer totalCuCount = report.getTotalCuCount();</span><br><span class="line">		Double oldCuRate = <span class="keyword">new</span> Double(SysContent.getTwoNumberForValue(oldCuCount, totalCuCount));</span><br><span class="line">		String oldCuStr = <span class="string">"2、累计老客户总量为"</span> + oldCuCount + <span class="string">"组，老客户占比为"</span> + oldCuRate + <span class="string">"%，显示老客户关注度"</span>;</span><br><span class="line">		<span class="keyword">if</span> (oldCuRate &lt; <span class="number">15</span>) &#123;</span><br><span class="line">			oldCuStr += <span class="string">"较低，有待提升"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (oldCuRate &gt;= <span class="number">15</span> &amp;&amp; oldCuRate &lt;= <span class="number">25</span>) &#123;</span><br><span class="line">			oldCuStr += <span class="string">"尚可，还有提高空间"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (oldCuRate &gt;= <span class="number">25</span> &amp;&amp; oldCuRate &lt;= <span class="number">40</span>) &#123;</span><br><span class="line">			oldCuStr += <span class="string">"很高"</span>;</span><br><span class="line">		&#125; <span class="keyword">else</span> <span class="keyword">if</span> (oldCuRate &gt; <span class="number">40</span>) &#123;</span><br><span class="line">			oldCuStr += <span class="string">"极高"</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		createCellAndRow(style4, oldCuStr, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 累计总储客</span></span><br><span class="line">		row = sheet.createRow(<span class="number">12</span>);</span><br><span class="line">		String totalOldCuStr = <span class="string">"3、累计总储客"</span> + totalCuCount + <span class="string">"组"</span>;</span><br><span class="line">		createCellAndRow(style4, totalOldCuStr, row);</span><br><span class="line"></span><br><span class="line">		<span class="comment">// 成交情况(周报没有，其他有)</span></span><br><span class="line">		<span class="keyword">if</span> (report.getSubscribeHouseCount() != <span class="keyword">null</span>) &#123;</span><br><span class="line">			</span><br><span class="line">			<span class="comment">//空行</span></span><br><span class="line">			row = sheet.createRow(<span class="number">13</span>);</span><br><span class="line">			createCellAndRow(style4, <span class="string">""</span>, row);</span><br><span class="line">			</span><br><span class="line">			row = sheet.createRow(<span class="number">14</span>);</span><br><span class="line">			createCellAndRow(style2, <span class="string">"·成交情况"</span>, row);</span><br><span class="line"></span><br><span class="line">			<span class="comment">// 新增认购套数</span></span><br><span class="line">			row = sheet.createRow(<span class="number">15</span>);</span><br><span class="line">			Integer subscribeHouseCount = report.getSubscribeHouseCount();</span><br><span class="line">			Double subscribeHouseRate = <span class="keyword">new</span> Double(report.getSubscribeHouseRate());</span><br><span class="line">			String subscribeHouseStr = <span class="string">"1、"</span> + dateStr + <span class="string">"新增认购套数"</span> + subscribeHouseCount + <span class="string">"套，较"</span> + dateStr + <span class="string">"同期"</span>;</span><br><span class="line">			<span class="keyword">if</span> (subscribeHouseRate &lt; <span class="number">0</span>) &#123;</span><br><span class="line">				subscribeHouseStr += <span class="string">"减少"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">				subscribeHouseStr += <span class="string">"增长"</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			subscribeHouseStr += Math.abs(subscribeHouseRate) + <span class="string">"%"</span>;</span><br><span class="line">			createCellAndRow(style4, subscribeHouseStr, row);</span><br><span class="line"></span><br><span class="line">			<span class="comment">// 新增认购金额</span></span><br><span class="line">			row = sheet.createRow(<span class="number">16</span>);</span><br><span class="line">			Long subscribeMoney = report.getSubscribeMoney();</span><br><span class="line">			Double subscribeMoneyRate = <span class="keyword">new</span> Double(report.getSubscribeMoneyRate());</span><br><span class="line">			String subscribeMoneyStr = <span class="string">"   新增认购金额"</span> + subscribeMoney + <span class="string">"万元，较"</span> + dateStr + <span class="string">"同期"</span>;</span><br><span class="line">			<span class="keyword">if</span> (subscribeHouseRate &lt; <span class="number">0</span>) &#123;</span><br><span class="line">				subscribeMoneyStr += <span class="string">"减少"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">				subscribeMoneyStr += <span class="string">"增长"</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			subscribeMoneyStr += Math.abs(subscribeMoneyRate) + <span class="string">"%"</span>;</span><br><span class="line">			createCellAndRow(style4, subscribeMoneyStr, row);</span><br><span class="line"></span><br><span class="line">			<span class="comment">// 新增签约套数</span></span><br><span class="line">			row = sheet.createRow(<span class="number">17</span>);</span><br><span class="line">			Integer signCount = report.getSignCount();</span><br><span class="line">			Double signRate = <span class="keyword">new</span> Double(report.getSignRate());</span><br><span class="line">			String signStr = <span class="string">"2、新增签约套数"</span> + signCount + <span class="string">"套,较"</span> + dateStr + <span class="string">"同期"</span>;</span><br><span class="line">			<span class="keyword">if</span> (signRate &lt; <span class="number">0</span>) &#123;</span><br><span class="line">				signStr += <span class="string">"减少"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">				signStr += <span class="string">"增长"</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			signStr += Math.abs(signRate) + <span class="string">"%"</span>;</span><br><span class="line">			createCellAndRow(style4, signStr, row);</span><br><span class="line"></span><br><span class="line">			<span class="comment">// 新增签约金额</span></span><br><span class="line">			row = sheet.createRow(<span class="number">18</span>);</span><br><span class="line">			Long signHouseMoney = report.getSignHouseMoney();</span><br><span class="line">			Double signHouseMoneyRate = <span class="keyword">new</span> Double(report.getSignHouseMoneyRate());</span><br><span class="line">			String signHouseMoneyStr = <span class="string">"   新增签约金额"</span> + signHouseMoney + <span class="string">"万元，较"</span> + dateStr + <span class="string">"同期"</span>;</span><br><span class="line">			<span class="keyword">if</span> (signHouseMoneyRate &lt; <span class="number">0</span>) &#123;</span><br><span class="line">				signHouseMoneyStr += <span class="string">"减少"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">				signHouseMoneyStr += <span class="string">"增长"</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			signHouseMoneyStr += Math.abs(signHouseMoneyRate) + <span class="string">"%"</span>;</span><br><span class="line">			createCellAndRow(style4, signHouseMoneyStr, row);</span><br><span class="line"></span><br><span class="line">			<span class="comment">// 新接访签约率</span></span><br><span class="line">			row = sheet.createRow(<span class="number">19</span>);</span><br><span class="line">			Double newCustomerSignedRate = <span class="keyword">new</span> Double(report.getNewCustomerSignedRate());</span><br><span class="line">			String newCustomerSignedStr = <span class="string">"3、"</span> + dateStr + <span class="string">"新客户接访签约率"</span> + newCustomerSignedRate + <span class="string">"%，接访签约概率"</span>;</span><br><span class="line">			<span class="keyword">if</span> (newCustomerSignedRate &lt; <span class="number">4</span>) &#123;</span><br><span class="line">				newCustomerSignedStr += <span class="string">"较低，与理想值差距大"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (newCustomerSignedRate &gt;= <span class="number">4</span> &amp;&amp; newCustomerSignedRate &lt;= <span class="number">6</span>) &#123;</span><br><span class="line">				newCustomerSignedStr += <span class="string">"尚可，还有提高空间"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (newCustomerSignedRate &gt;= <span class="number">6</span> &amp;&amp; newCustomerSignedRate &lt;= <span class="number">7</span>) &#123;</span><br><span class="line">				newCustomerSignedStr += <span class="string">"很高"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (newCustomerSignedRate &gt; <span class="number">7</span>) &#123;</span><br><span class="line">				newCustomerSignedStr += <span class="string">"非常高"</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			createCellAndRow(style4, newCustomerSignedStr, row);</span><br><span class="line"></span><br><span class="line">			<span class="comment">// 储客签约率</span></span><br><span class="line">			row = sheet.createRow(<span class="number">20</span>);</span><br><span class="line">			Double momeryCustomerSignedRate = <span class="keyword">new</span> Double(report.getMomeryCustomerSignedRate());</span><br><span class="line">			String momeryCustomerSignedStr = <span class="string">"4、储客签约率"</span> + momeryCustomerSignedRate + <span class="string">"%，储备客户签约概率"</span>;</span><br><span class="line">			<span class="keyword">if</span> (momeryCustomerSignedRate &lt; <span class="number">7</span>) &#123;</span><br><span class="line">				momeryCustomerSignedStr += <span class="string">"较低，与理想值差距大"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (momeryCustomerSignedRate &gt;= <span class="number">7</span> &amp;&amp; momeryCustomerSignedRate &lt;= <span class="number">12</span>) &#123;</span><br><span class="line">				momeryCustomerSignedStr += <span class="string">"尚可，还有提高空间"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (momeryCustomerSignedRate &gt;= <span class="number">12</span> &amp;&amp; momeryCustomerSignedRate &lt;= <span class="number">15</span>) &#123;</span><br><span class="line">				momeryCustomerSignedStr += <span class="string">"很高"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (momeryCustomerSignedRate &gt; <span class="number">15</span>) &#123;</span><br><span class="line">				momeryCustomerSignedStr += <span class="string">"非常高"</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			createCellAndRow(style4, momeryCustomerSignedStr, row);</span><br><span class="line"></span><br><span class="line">			<span class="comment">// 老客户签约率</span></span><br><span class="line">			row = sheet.createRow(<span class="number">21</span>);</span><br><span class="line">			Double oldCustomerSignedRate = <span class="keyword">new</span> Double(report.getOldCustomerSignedRate());</span><br><span class="line">			String oldCustomerSignedStr = <span class="string">"5、老客户签约率为23.2%，高意向客户签约概率"</span>;</span><br><span class="line">			<span class="keyword">if</span> (oldCustomerSignedRate &lt; <span class="number">25</span>) &#123;</span><br><span class="line">				oldCustomerSignedStr += <span class="string">"较低，与理想值差距大"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (oldCustomerSignedRate &gt;= <span class="number">25</span> &amp;&amp; oldCustomerSignedRate &lt;= <span class="number">35</span>) &#123;</span><br><span class="line">				oldCustomerSignedStr += <span class="string">"尚可，还有提高空间"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (oldCustomerSignedRate &gt;= <span class="number">35</span> &amp;&amp; oldCustomerSignedRate &lt;= <span class="number">50</span>) &#123;</span><br><span class="line">				oldCustomerSignedStr += <span class="string">"很高"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (oldCustomerSignedRate &gt; <span class="number">50</span>) &#123;</span><br><span class="line">				oldCustomerSignedStr += <span class="string">"非常高"</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			createCellAndRow(style4, oldCustomerSignedStr, row);</span><br><span class="line"></span><br><span class="line">			<span class="comment">// 认购客户签约率</span></span><br><span class="line">			row = sheet.createRow(<span class="number">22</span>);</span><br><span class="line">			Double contratCuSignedRate = <span class="keyword">new</span> Double(report.getContratCuSignedRate());</span><br><span class="line">			String contratCuSignedStr = <span class="string">"6、认购客户签约率为92%，已认购客户签约率"</span>;</span><br><span class="line">			<span class="keyword">if</span> (contratCuSignedRate &lt; <span class="number">95</span>) &#123;</span><br><span class="line">				contratCuSignedStr += <span class="string">"不高，较多退订或拒签"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (contratCuSignedRate &gt;= <span class="number">95</span> &amp;&amp; contratCuSignedRate &lt;= <span class="number">97</span>) &#123;</span><br><span class="line">				contratCuSignedStr += <span class="string">"尚可，一定数量退订或拒签"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (contratCuSignedRate &gt;= <span class="number">97</span> &amp;&amp; contratCuSignedRate &lt;= <span class="number">99</span>) &#123;</span><br><span class="line">				contratCuSignedStr += <span class="string">"很高"</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> <span class="keyword">if</span> (contratCuSignedRate &gt; <span class="number">99</span>) &#123;</span><br><span class="line">				contratCuSignedStr += <span class="string">"非常高"</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			createCellAndRow(style4, contratCuSignedStr, row);</span><br><span class="line"></span><br><span class="line">			<span class="comment">//空行</span></span><br><span class="line">			row = sheet.createRow(<span class="number">23</span>);</span><br><span class="line">			createCellAndRow(style4, <span class="string">""</span>, row);</span><br><span class="line">			</span><br><span class="line">			<span class="comment">//底侧</span></span><br><span class="line">			row = sheet.createRow(<span class="number">24</span>);</span><br><span class="line">			createCellAndRow(style5, <span class="string">""</span>, row);</span><br><span class="line">			</span><br><span class="line">		&#125;<span class="keyword">else</span>&#123;</span><br><span class="line">			row = sheet.createRow(<span class="number">13</span>);</span><br><span class="line">			createCellAndRow(style5, <span class="string">""</span>, row);</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		<span class="keyword">try</span> &#123;</span><br><span class="line">			workbook.write(out);</span><br><span class="line">		&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">createCellAndRow</span><span class="params">(HSSFCellStyle style, String text, HSSFRow row)</span> </span>&#123;</span><br><span class="line">		HSSFCell cell = row.createCell(<span class="number">0</span>);</span><br><span class="line">		cell.setCellStyle(style);</span><br><span class="line">		HSSFRichTextString rs = <span class="keyword">new</span> HSSFRichTextString(text);</span><br><span class="line">		cell.setCellValue(rs);</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 上传Excel</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> fileNewName</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> uploadFile</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">static</span> String <span class="title">uploadExcel</span><span class="params">(String fileNewName,ByteArrayInputStream uploadFile)</span></span>&#123;</span><br><span class="line">		<span class="comment">// 设置用户属性, 包括appid, secretId和SecretKey</span></span><br><span class="line">				<span class="comment">// 这些属性可以通过cos控制台获取(https://console.qcloud.com/cos)</span></span><br><span class="line">				String version = PropertiesUtil.getValue(<span class="string">"version"</span>);</span><br><span class="line">					 <span class="keyword">long</span> appId = <span class="string">"你的appId"</span>;</span><br><span class="line">	                 String secretId = <span class="string">"你的secretId "</span>;</span><br><span class="line">	                 String secretKey = <span class="string">"你的secretKey "</span>;</span><br><span class="line">				</span><br><span class="line">				<span class="comment">// 设置要操作的bucket</span></span><br><span class="line">				String bucketName = <span class="string">"root"</span>;</span><br><span class="line">				<span class="comment">// 初始化客户端配置</span></span><br><span class="line">				ClientConfig clientConfig = <span class="keyword">new</span> ClientConfig();</span><br><span class="line">				<span class="comment">// 设置bucket所在的区域，比如广州(gz), 天津(tj)</span></span><br><span class="line">				clientConfig.setRegion(<span class="string">"sh"</span>);</span><br><span class="line">				<span class="comment">// 初始化秘钥信息</span></span><br><span class="line">				Credentials cred = <span class="keyword">new</span> Credentials(appId, secretId, secretKey);</span><br><span class="line">				<span class="comment">// 初始化cosClient</span></span><br><span class="line">				COSClient cosClient = <span class="keyword">new</span> COSClient(clientConfig, cred);</span><br><span class="line">				<span class="comment">// 文件操作 //</span></span><br><span class="line">				<span class="comment">// 1. 上传文件(默认不覆盖)</span></span><br><span class="line">				<span class="comment">// 将本地的local_file_1.txt上传到bucket下的根分区下,并命名为sample_file.txt</span></span><br><span class="line">				<span class="comment">// 默认不覆盖, 如果cos上已有文件, 则返回错误</span></span><br><span class="line">				String cosFilePath = <span class="string">"/report/"</span> + fileNewName;</span><br><span class="line">				</span><br><span class="line">				<span class="keyword">byte</span>[] localFilePath1 = <span class="keyword">null</span>;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					localFilePath1 = ConvertUtil.toByteArray(uploadFile);</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e1) &#123;</span><br><span class="line">					<span class="comment">// TODO Auto-generated catch block</span></span><br><span class="line">					e1.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">				</span><br><span class="line">				UploadFileRequest uploadFileRequest = <span class="keyword">new</span> UploadFileRequest(bucketName, cosFilePath, localFilePath1);</span><br><span class="line">				uploadFileRequest.setEnableShaDigest(<span class="keyword">false</span>);</span><br><span class="line">				String uploadFileRet = cosClient.uploadFile(uploadFileRequest);</span><br><span class="line">				System.out.println(<span class="string">"upload file ret:"</span> + uploadFileRet);</span><br><span class="line">				<span class="comment">//获取保存路径</span></span><br><span class="line">				ObjectMapper om = <span class="keyword">new</span> ObjectMapper();</span><br><span class="line">				HashMap map = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					map = om.readValue(uploadFileRet, HashMap.class);</span><br><span class="line">				&#125; <span class="keyword">catch</span> (JsonParseException e) &#123;</span><br><span class="line">					<span class="comment">// TODO Auto-generated catch block</span></span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (JsonMappingException e) &#123;</span><br><span class="line">					<span class="comment">// TODO Auto-generated catch block</span></span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					<span class="comment">// TODO Auto-generated catch block</span></span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">				HashMap&lt;String, String&gt; value = (HashMap&lt;String, String&gt;) map.get(<span class="string">"data"</span>);</span><br><span class="line">				<span class="keyword">return</span> value.get(<span class="string">"source_url"</span>);</span><br><span class="line">				</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">addReportExcelToDB</span><span class="params">(ReportResult rr, String url)</span> </span>&#123;</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">if</span>(StringUtils.isEmpty(url))&#123;</span><br><span class="line">			<span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span>(rr == <span class="keyword">null</span>)&#123;</span><br><span class="line">			<span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		</span><br><span class="line">		ProjectReportRecord prr = <span class="keyword">new</span> ProjectReportRecord();</span><br><span class="line">		prr.setCreateTime(DateUtil.format(<span class="keyword">new</span> Date()));</span><br><span class="line">		prr.setProjectId(rr.getProjectId());</span><br><span class="line">		prr.setProjectName(rr.getProjectName());</span><br><span class="line">		prr.setStartTime(rr.getStartTime());</span><br><span class="line">		prr.setEndTime(rr.getEndTime());</span><br><span class="line">		prr.setUrl(url);</span><br><span class="line">		String report = <span class="string">""</span>;</span><br><span class="line">		<span class="keyword">if</span>(<span class="string">"案场周报"</span>.equals(rr.getReportName()))&#123;</span><br><span class="line">			report = <span class="string">"week"</span>;</span><br><span class="line">		&#125;<span class="keyword">else</span> <span class="keyword">if</span>(<span class="string">"案场月报"</span>.equals(rr.getReportName()))&#123;</span><br><span class="line">			report = <span class="string">"month"</span>;</span><br><span class="line">		&#125;<span class="keyword">else</span> <span class="keyword">if</span>(<span class="string">"案场季报"</span>.equals(rr.getReportName()))&#123;</span><br><span class="line">			report = <span class="string">"quarter"</span>;</span><br><span class="line">		&#125;<span class="keyword">else</span> <span class="keyword">if</span>(<span class="string">"案场半年报"</span>.equals(rr.getReportName()))&#123;</span><br><span class="line">			report = <span class="string">"half"</span>;</span><br><span class="line">		&#125;<span class="keyword">else</span> <span class="keyword">if</span>(<span class="string">"案场年报"</span>.equals(rr.getReportName()))&#123;</span><br><span class="line">			report = <span class="string">"year"</span>;</span><br><span class="line">		&#125;<span class="keyword">else</span>&#123;</span><br><span class="line">			report = <span class="string">"other"</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		prr.setReportName(report);</span><br><span class="line">		</span><br><span class="line">		baseDao.save(prr);</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">return</span> <span class="keyword">true</span>;</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<h3 id="生成的文件示例"><a href="#生成的文件示例" class="headerlink" title="生成的文件示例"></a>生成的文件示例</h3><p><strong>周报或者其他报告都是后台自动根据时间进行判断的</strong></p>
<p><strong>周报</strong><br><img src="http://img.blog.csdn.net/20171020105154962?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvV2ludGVyX2NoZW4wMDE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p>
<p><strong>季报</strong></p>
<p><img src="http://img.blog.csdn.net/20171020105212669?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvV2ludGVyX2NoZW4wMDE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p>
<p>以上</p>

            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls" data-autoplay="false">
                <source type="audio/mpeg" src="">
            </audio>
            
                <ul id="audio-list" style="display:none">
                    
                        
                            <li title='0' data-url='https://raw.githubusercontent.com/WinterChenS/imgrpo/master/mp3/%E6%96%B0%E8%A3%A4%E5%AD%90-%E7%94%9F%E6%B4%BB%E5%9B%A0%E4%BD%A0%E8%80%8C%E7%81%AB%E7%83%AD.mp3'></li>
                        
                    
                </ul>
            
        </div>
        
    <div id='gitalk-container' class="comment link"
		data-enable='false'
        data-ae='false'
        data-ci='77f2adc33e0112d086d7'
        data-cs='e926aa3a621556609b2c2b76d89320fa524e23cd'
        data-r='WinterChenS.github.io'
        data-o='WinterChenS'
        data-a='WinterChenS'
        data-d='false'
    >查看评论</div>


    </div>
    
</div>


    </div>
</div>
</body>


<script src="//lib.baomitu.com/jquery/1.8.3/jquery.min.js"></script>
<script src="/js/plugin.js"></script>
<script src="/js/typed.js"></script>
<script src="/js/diaspora.js"></script>


<link rel="stylesheet" href="/photoswipe/photoswipe.css">
<link rel="stylesheet" href="/photoswipe/default-skin/default-skin.css">


<script src="/photoswipe/photoswipe.min.js"></script>
<script src="/photoswipe/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>





<!-- Google Analytics -->
<script type="text/javascript">
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'G-30C04D6TMS', 'auto');
  ga('send', 'pageview');
</script>
<!-- End Google Analytics -->


</html>
